import axios from "axios";

let jsonData ={code:1, message:'',data:{}}

/* axios({
    method:"post", 
    url:"http://localhost:9988/user/login",  
    data:{ 
        username:"zhangfei",
        userPwd:"123456"
    } 
}).then(function(response){ //响应成功时要执行的函数  then取返回值
    //JSON.parse  JSON.stringify
    console.log(JSON.stringify(response.data))
    console.log("=========================")
    Object.assign(jsonData, response.data)
    console.log(jsonData)
}).catch(function (error){// 响应失败时要执行的函数
    console.log(error)
}) */




/* let ret = function fun1(){

    return axios({
        method:"post",
        url:"http://localhost:9988/user/login",
        data:{
        username:"zhangfei",
        userPwd:"123456"
        }
    })
}
 */
//ret()
//console.log(ret)


/* async function method1(){
    return await axios({
        method:"post",
        url:"http://localhost:9988/user/login",
        data:{
            username:"zhangfei",
            userPwd:"123456"
        }
    })    
} */

/* async function method2(){
   let ret =  await method1()

   console.log(ret.data.data.token)
}

method2() */

/* function method1(a, b){
    return a+b;
}

let ret1 = method1(10,100)
console.log(ret1)
 */

/* let ret2 = function method2(){
    return axios({
        method:"post",
        url:"http://localhost:9988/user/login",
        data:{
        username:"zhangfei",
        userPwd:"123456"
        }
    })
} */
//[Function: method2]
//Promise { <pending> }
//console.log(ret2())

/* ret2().then(
    (response)=>{
        console.log(response.data.data)
    }
) */



/* console.log(ret3().then(
    (response)=>{
        console.log(response.data.data)

        let pro = axios.get(
            'http://localhost:9988/user/getUserInfo',
            {
                params:{
                    token:'eyJhbGciOiJIUzUxMiIsInppcCI6IkdaSVAifQ.H4sIAAAAAAAA_6tWKi5NUrJSiox099ANDXYNUtJRSq0oULIyNDcxNDY2sTAx1VEqLU4t8kwBitUCABTFQsIvAAAA.LlBOQFtE4UnfjSIVObSCP6zxHJ76jhT3Tn4fyFvAHOQ9kUq08C1XKeJ-q6L1_nDfizLW9INsDkHQTrFmQCUY2Q'
                }
            }
        )

        pro.then(
            (data) => {
                console.log(data.data.data)
            }
        )

    }
)) */

/* async function method2(){
    return await axios({
        method:"post",
        url:"http://localhost:9988/user/login",
        data:{
        username:"zhangfei",
        userPwd:"123456"
        }
    })
} */

/* async function method3(){
     let ret = await method2()
      axios.get(
        'http://localhost:9988/user/getUserInfo',
        {
            params:{
                token:ret.data.data.token
            }
        }
    ).then(
        (info) => {
            console.log(info.data.data)
        }
    ) 

    let ret3 = await axios.get(
        'http://localhost:9988/user/getUserInfo',
        {
            params:{
                token:ret.data.data.token
            }
        }
    )

    console.log(ret3.data.data)
} */

/* method3() */

//创建instance实例
/* const service = axios.create({
    baseURL: "http://localhost:9988/",
    timeout: 50000,
}); */

/* let ret111 = async function method3(){
    return await service({
        method:"post", 
        url:"/user/login",  
        data:{ 
            username:"zhangfei",
            userPwd:"123456"
        }
    })
} */

/* console.log(await service({
    method:"post", 
    url:"/user/login",  
    data:{ 
        username:"zhangfei",
        userPwd:"123456"
    }
})) */


/* .then(function(response){
    console.log(JSON.stringify(response.data))
    console.log("=========================")
    Object.assign(jsonData, response.data)
    console.log(jsonData)
}).catch(function (error){
    console.log(error)
}) */


/* import { defineStore } from "pinia";

export const useInfoStore = defineStore(
    'info1',
    {
        state: ()=>({
            name: 'zhangfei',
            pwd:'123456'
        }),
        getters:{
            isLogin: ()=>{
                state.params === '123456'
            }
        },
        actions: {
            method1(){
                console.log("1212121")
            }
        }
    }
)  */

///////////
/* import { useInfoStore } from '@/untils/learn';
const infoStore =  useInfoStore()
console.log(infoStore.name) */